#!/usr/bin/perl
#lvformat.cgi
require './lvm-lib.pl';
&ReadParse();

my ($err_msg, $log_ev, $log_msg, $log_pri);
my ($lvdev, $voldir, @lvinfo, $l, $lv);
$config{'mkfs_lock_new'} = "/var/nas/lock/mkfsd_new";
$err_msg="";
$log_ev="";

$lvdev = $in{'lv'};
@lvinfo = get_lv_info();

if(!$lvdev){
	$err_msg = $text{'err_noselectlv'};
	goto ERROR_OUT;
}

my $found = 0;
foreach $l (@lvinfo) {
	if ($l->{'lv'} eq $lvdev) {
		$lv = $l;
		$found = 1;
		last;
	}
} 
if(!$found){
	$err_msg = $text{'err_lvnofound'};
	goto ERROR_OUT;
}

if($lv->{'lvname'} =~ /volume\d+/){
	$voldir = "/usrvol/".$lv->{'lvname'};
}
else{
	$err_msg = $text{'err_errlvpath'};
	goto ERROR_OUT;
}

#begin mkfs. Because mkfs is very time consumed, fork a child process

&header("$text{'chsfs_header'}", "","choosefs", undef, 0);
print "<form name=choosefs action=lvformat.cgi method=post>\n";
print "<table class=mode1 width=80%>";
print "<tr><td width=150><b>$text{'chsfs_filesystem'}</b></td>";
print "<td width=200><select name=type class=drop>";
print "<option selected value=ext3>ext3";
print "<option value=xfs>xfs";
print "</select></td>";
print "<td><input type=submit class=button1 name=ok value=$text{'chsfs_submit'}></td></tr>";
print "</table>";

print "<input type=hidden name=lvdev value=$lvdev>\n";
print "<input type=hidden name=voldir value=$voldir>";
print "</form>\n";
#&footer("index.cgi", "back");

ERROR_OUT:
&error_setup($text{'crt_err_title'});
&error($err_msg);


